﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using DTO;
using BUS;


namespace Presentation
{
    public partial class frm_Main : Form
    {
        DangNhapBUS dnBUS = new DangNhapBUS();
        DangNhapDTO dnDTO = new DangNhapDTO();


        public frm_Main()
        {
            InitializeComponent();
        }
        private void mnDangNhap_Click(object sender, EventArgs e)
        {

            //frm_KetNoiDatabase db = new frm_KetNoiDatabase();
            //db.ShowDialog();
        }
    }
}
        
        /*#region
        //Cac ham xu ly login va phan quyen
        private void DisableMenuLogin(bool logged,string maquyen)
        {   

                //neu dang nhap thanh cong thi tat menu dang nhap
                mnDangNhap.Enabled = !logged;
                //neu dang nhap thanh cong thi bat menu dang xuat
                mnDangXuat.Enabled = logged;
                //mac dinh neu dang nhap thanh cong thi bat het cac menu con lai
                mnHeThong.Enabled = logged;
                mnDoiMatKhau.Enabled = logged;
                mnThoat.Enabled = logged;
                mnChucNang.Enabled = logged;
                mnNhanLich.Enabled = logged;
                mnBanVe.Enabled = logged;
                mnGhiNhan.Enabled = logged;
                mnTraCuu.Enabled = logged;
                mnBaoCaoThang.Enabled = logged;
                mnBaoCaoNam.Enabled = logged;
                mnQuanLy.Enabled = logged;
                mnChuyenBay.Enabled = logged;
                mnSanBay.Enabled = logged;
                mnTuyenBay.Enabled = logged;
                mnQuiDinh.Enabled = logged;
                itemQDChuyenBay.Enabled = logged;
                itemQDSLHangVe_Gia.Enabled = logged;
                itemQDThoiHanDatVe.Enabled = logged;
            
            //phan quyen theo user
            switch (maquyen)
            { 
                case"Q001": break;
                case "Q002": HienThiQuyenUser();break;
            }
        }
        private void HienThiQuyenUser()
        {
            mnQuanLy.Enabled =false;
            mnChuyenBay.Enabled = false;
            mnSanBay.Enabled = false;
            mnTuyenBay.Enabled = false;
            mnQuiDinh.Enabled = false;
            itemQDThoiHanDatVe.Enabled = false;
            itemQDSLHangVe_Gia.Enabled = false;
            itemQDChuyenBay.Enabled = false;

        }
        #endregion
        private void frm_Main_Load(object sender, EventArgs e)
        {  
            DisableMenuLogin(false,null);
        }
        frm_DangNhap fdn = null;
        private void mnSanBay_Click(object sender, EventArgs e)
        {
            //frm_SanBay sb = new frm_SanBay();
           // sb.Show();
        }

       

        private void mnDangNhap_Click(object sender, EventArgs e)
        {
            /*<<<<<<< .mine
                        //frm_KetNoiDatabase db = new frm_KetNoiDatabase();
                       // db.ShowDialog();


            =======
            >>>>>>> .r10
           
                        int numsErrorPassword = 0;
                        Cont:
      
                        if(fdn==null || fdn.IsDisposed)
                        fdn = new frm_DangNhap();
                        if (fdn.ShowDialog() == DialogResult.OK)
                        {
                            string user = fdn.txtHoTen.Text;
                            string pass = fdn.txtMatKhau.Text;
                            if (user.Equals(""))
                            {
                                fdn.lblTrangThai.Text = "User khong hop le";
                                goto Cont;
                            }
                            if (pass.Equals(""))
                            {
                                fdn.lblTrangThai.Text = "Pass khong hop le";
                                goto Cont;
                            }
                            dnDTO = dnBUS.LayThongTinUser(user);
                            if (dnDTO.Hoten.Equals(""))
                            {
                                fdn.lblTrangThai.Text = "User khong ton tai";
                                goto Cont;
                            }
                            if (dnDTO.Password != pass)
                            {
                                fdn.lblTrangThai.Text = "pass sai";
                                numsErrorPassword++;
                                if (numsErrorPassword == 3)
                                    this.Close();
                                goto Cont;  
                            }
                            DisableMenuLogin(true,dnDTO.Maquyen);
                        }*/
     

      
       
 
